/**
 * Created by wuhaiyang on 2017/4/13.
 */


import React, {Component} from 'react'

import {
    Text,
    View,
    TouchableOpacity,
    StyleSheet
} from 'react-native'

import NavigationToolbar1 from '../widget/NavigationToolbar1'
import ComponentY from './ComponentY'
export default class ComponentX extends Component {

    constructor(props) {
        super(props)
        this.state = {
            goods: ''
        }
    }

    startComponentY() {
        this.props.navigator.push({
            component: ComponentY,
            params: {
                ...this.props,
                onDataCallback: (goods) => {
                    this.setState({
                        goods: goods
                    })
                },
                money:'20元'
            }
        })
    }

    render() {
        return (
            <View style={styles.container}>

                <NavigationToolbar1
                    title={'我是买家'}
                />
                <View style={{flex:1,alignItems:'center',justifyContent:'center'}}>
                    <TouchableOpacity
                        onPress={()=>this.startComponentY()}
                        style={{padding:10}}
                    >
                        <Text>
                            点击我跳转到ComponentY
                        </Text>
                    </TouchableOpacity>
                    <Text> 获取到卖家的货物是：{this.state.goods}</Text>
                </View>

            </View>
        )
    }
}

const styles = {
    container: {
        flex: 1
    }
}